function cycle(n ,m) {
  let all = n;
  // 100个人的环
  let cycleList = new Array(all).fill(0);
  let i = 0;
  let step = 0;
  let count = 0;
  let len = all;
  while (true) {
    let value = cycleList[i];
    // 遇到已经标记过的，跳过
    if(value === 1) {
      i++;
      if(i >= all) {
        i = 0;
      }
      continue;
    }
    step++;
    // 遇到m数字，将其标记为1
    if(step === m) {
      cycleList[i] = 1;
      // 统计已经剩余个数
      count++;
      step = 0;
    }
    if(len - count < m) {
      break;
    }
    i++;
    // 一轮循环结束，继续下一次循环
    if(i >= all) {
      i = 0;
    }
  }
  let result = [];
  // console.log(cycleList)
  cycleList.forEach((v, i) => {
    if(v != 1) {
      result.push(i+1);
    }
  })
  return result.join(',');
}
console.time('begin')
console.log(cycle(100, 0));
console.timeEnd('begin')